﻿package 
{
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.ProgressEvent;
	import flash.display.Loader;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.media.Sound;
	import com.hp.acg.mmt.*;



	public class OfficeJet_7000_AS_3 extends MovieClip
	{

		private var bgMC:MovieClip;
		private var arrowMC:MovieClip;
		private var insMC:MovieClip;
		private var tipsMC:MovieClip;
		private var resultMC:MovieClip;
		private var returnMC:MovieClip;


		private var firstLight:MovieClip;
		private var secondLight:MovieClip;
		private var thirdLight:MovieClip;
		private var fourthLight:MovieClip;


		private var firstPopOut:MovieClip;
		private var secondPopOut:MovieClip;
		private var thirdPopOut:MovieClip;
		private var fourthPopOut:MovieClip;


		private var a:int = 1;
		private var b:int = 1;
		private var c:int = 1;
		private var d:int = 1;



		public function OfficeJet_7000_AS_3()
		{

			initUI();
			//stage.scaleMode = "noScale";

		}

		private function initUI():void
		{
			bgMC = new mc_back  ;
			arrowMC = new mc_arrow  ;
			insMC = new mc_instruction  ;
			tipsMC = new mc_tips  ;
			returnMC = new mc_returnBtn  ;
			resultMC = new mc_result  ;

			firstLight = new light1  ;
			secondLight = new light2  ;
			thirdLight = new light3  ;
			fourthLight = new light4  ;


			firstPopOut = new light1_popout  ;
			secondPopOut = new light2_popout  ;
			thirdPopOut = new light3_popout  ;
			fourthPopOut = new light4_popout  ;

			bgMC.name = "bgMC";
			arrowMC.name = "arrowMC";
			insMC.name = "insMC";
			tipsMC.name = "tipsMC";
			returnMC.name = "returnMC";
			resultMC.name = "resultMC";

			firstLight.name = "firstLight";
			secondLight.name = "secondLight";
			thirdLight.name = "thirdLight";
			fourthLight.name = "fourthLight";


			firstPopOut.name = "firstPopOut";
			secondPopOut.name = "secondPopOut";
			thirdPopOut.name = "thirdPopOut";
			fourthPopOut.name = "fourthPopOut";


			firstLight.gotoAndStop(1);
			secondLight.gotoAndStop(1);
			thirdLight.gotoAndStop(1);
			fourthLight.gotoAndStop(1);

			addChild(bgMC);
			addChild(arrowMC);
			addChild(tipsMC);
			addChild(insMC);
			addChild(resultMC);
			addChild(returnMC);

			addChild(firstLight);
			addChild(secondLight);
			addChild(thirdLight);
			addChild(fourthLight);


			addChild(firstPopOut);
			addChild(secondPopOut);
			addChild(thirdPopOut);
			addChild(fourthPopOut);


			//insMC.visible=false; 
			returnMC.buttonMode = true;
			resultMC.visible = false;
			returnMC.visible = false;
			//btn.addEventListener(MouseEvent.CLICK,btnHandler)
			//insMC.checkBtn.buttonMode=true;

			firstLight.buttonMode = true;
			secondLight.buttonMode = true;
			thirdLight.buttonMode = true;
			fourthLight.buttonMode = true;


			firstPopOut.visible = false;
			secondPopOut.visible = false;
			thirdPopOut.visible = false;
			fourthPopOut.visible = false;

			//insMC.checkBtn.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);

			firstLight.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);
			secondLight.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);
			thirdLight.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);
			fourthLight.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);


			//insMC.checkBtn.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);

			firstLight.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);
			secondLight.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);
			thirdLight.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);
			fourthLight.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);


			firstPopOut.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);
			secondPopOut.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);
			thirdPopOut.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);
			fourthPopOut.addEventListener(MouseEvent.ROLL_OVER,onRollOverHandler);


			firstPopOut.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);
			secondPopOut.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);
			thirdPopOut.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);
			fourthPopOut.addEventListener(MouseEvent.ROLL_OUT,onRollOutHandler);


			firstPopOut.btn1.buttonMode = true;
			firstPopOut.btn2.buttonMode = true;

			secondPopOut.btn1.buttonMode = true;
			secondPopOut.btn2.buttonMode = true;
			secondPopOut.btn3.buttonMode = true;

			thirdPopOut.btn1.buttonMode = true;
			thirdPopOut.btn2.buttonMode = true;

			fourthPopOut.btn1.buttonMode = true;
			fourthPopOut.btn2.buttonMode = true;
			fourthPopOut.btn3.buttonMode = true;
			fourthPopOut.btn4.buttonMode = true;
			fourthPopOut.btn5.buttonMode = true;



			insMC.checkBtn.addEventListener(MouseEvent.CLICK,onClickHandler);
			returnMC.addEventListener(MouseEvent.CLICK,onClickHandler);

			firstPopOut.btn1.addEventListener(MouseEvent.CLICK,onClickHandler);
			firstPopOut.btn2.addEventListener(MouseEvent.CLICK,onClickHandler);

			secondPopOut.btn1.addEventListener(MouseEvent.CLICK,onClickHandler);
			secondPopOut.btn2.addEventListener(MouseEvent.CLICK,onClickHandler);
			secondPopOut.btn3.addEventListener(MouseEvent.CLICK,onClickHandler);

			thirdPopOut.btn1.addEventListener(MouseEvent.CLICK,onClickHandler);
			thirdPopOut.btn2.addEventListener(MouseEvent.CLICK,onClickHandler);

			fourthPopOut.btn1.addEventListener(MouseEvent.CLICK,onClickHandler);
			fourthPopOut.btn2.addEventListener(MouseEvent.CLICK,onClickHandler);
			fourthPopOut.btn3.addEventListener(MouseEvent.CLICK,onClickHandler);
			fourthPopOut.btn4.addEventListener(MouseEvent.CLICK,onClickHandler);
			fourthPopOut.btn5.addEventListener(MouseEvent.CLICK,onClickHandler);



		}
		private function setVisibleFalseHandler():void
		{
			bgMC.visible = false;
			insMC.visible = false;


			firstLight.visible = false;
			secondLight.visible = false;
			thirdLight.visible = false;
			fourthLight.visible = false;

			firstPopOut.visible = false;
			secondPopOut.visible = false;
			thirdPopOut.visible = false;
			fourthPopOut.visible = false;



		}
		private function setVisibleTrueHandler():void
		{
			bgMC.visible = true;
			insMC.visible = true;

			firstLight.visible = true;
			secondLight.visible = true;
			thirdLight.visible = true;
			fourthLight.visible = true;



		}

		private function onClickHandler(e:MouseEvent):void
		{
			resultMC.visible = false;
			resultMC.gotoAndStop(1);
			insMC.visible = true;

			trace(e.currentTarget.name);
			switch (e.currentTarget)
			{
				case firstPopOut.btn1 :
					a = 1;
					firstLight.gotoAndStop(1);
					break;
				case firstPopOut.btn2 :
					a = 2;
					firstLight.gotoAndStop(2);
					break;

				case secondPopOut.btn1 :
					b = 1;
					secondLight.gotoAndStop(1);
					break;
				case secondPopOut.btn2 :
					b = 2;
					secondLight.gotoAndStop(2);
					break;
				case secondPopOut.btn3 :
					b = 3;
					secondLight.gotoAndStop(3);
					break;
				case thirdPopOut.btn1 :
					c = 1;
					thirdLight.gotoAndStop(1);
					break;
				case thirdPopOut.btn2 :
					c = 2;
					thirdLight.gotoAndStop(2);
					break;
				case fourthPopOut.btn1 :
					d = 1;
					fourthLight.gotoAndStop(1);
					break;
				case fourthPopOut.btn2 :
					d = 2;
					fourthLight.gotoAndStop(2);
					break;
				case fourthPopOut.btn3 :
					d = 3;
					fourthLight.gotoAndStop(3);
					break;
				case fourthPopOut.btn4 :
					d = 4;
					fourthLight.gotoAndStop(4);
					break;
				case fourthPopOut.btn5 :
					d = 5;
					fourthLight.gotoAndStop(5);
					break;
				case insMC.checkBtn :
					resultMC.visible = true;
					resultMC.gotoAndStop("t_"+a+b+c+d);
					if (null)
					{
						resultMC.gotoAndStop("t_0");
					}
					setVisibleFalseHandler();
					returnMC.visible = true;
					returnMC.visible = true;
					break;
				case returnMC :
					setVisibleTrueHandler();
					returnMC.visible = false;
					break;

				default :
			}
			if (a == 2)
			{
				firstLight.gotoAndStop(1);
				firstLight.gotoAndStop(2);
			}
			if (b == 3)
			{
				secondLight.gotoAndStop(1);
				secondLight.gotoAndStop(3);
			}
			if (d == 3)
			{
				fourthLight.gotoAndStop(1);
				fourthLight.gotoAndStop(3);
			}
			if (d == 4)
			{
				fourthLight.gotoAndStop(1);
				fourthLight.gotoAndStop(4);
			}

			trace("t_"+a+b+c+d);
		}

		private function onRollOverHandler(e:Event):void
		{
			tipsMC.visible = false;
			//trace(e.currentTarget.name+"  aaaaaaaaaaaaaaaaaaaaaaaaaaaa");
			switch (e.currentTarget)
			{
				case firstLight :
					firstPopOut.visible = true;
					break;
				case secondLight :
					secondPopOut.visible = true;
					break;
				case thirdLight :
					thirdPopOut.visible = true;
					break;
				case fourthLight :
					fourthPopOut.visible = true;
					break;
				case firstPopOut :
					firstPopOut.visible = true;
					break;
				case secondPopOut :
					secondPopOut.visible = true;
					break;
				case thirdPopOut :
					thirdPopOut.visible = true;
					break;
				case fourthPopOut :
					fourthPopOut.visible = true;
					break;
				default :
			}

		}
		private function onRollOutHandler(e:Event):void
		{

			firstPopOut.visible = false;
			secondPopOut.visible = false;
			thirdPopOut.visible = false;
			fourthPopOut.visible = false;
			tipsMC.visible = true;

		}
	}
}